<template>
<Row class="layout-content-body">
    <dtable :columnsList="columns" v-model="dataAll" :totals="total" 
    check approve read  
    @approveClick="approveClick" 
    @get="get" @refresh="getall()" :loading="loading"></dtable>
</Row>
</template>

<script>
import { timeFormat, currency } from '@/common/filter'
import dtable from '@/components/table/etable.vue' // 采用biztable
export default {
    data () {
        return {
            loading: false, // 数据刷新遮罩层
            columns: [
        // 多选框
                {
                    title: '案件名称',
                    key: 'Title',
                    sortable: true
                },
                {
                    title: '案件编号',
                    key: 'No',
                    sortable: true
                },
                {
                    title: '单位',
                    key: 'DeptName',
                    sortable: true
                },
                {
                    title: '是否初检',
                    key: 'First',
                    sortable: true,
                    render: (h, { row }) => {
                        let str = row.First == 1 ? '是' : '否'
                        return h('span', {}, str)
                    }
                },
                {
                    title: '鉴定类型',
                    key: '',
                    sortable: true,
                    render: (h, { row }) => {
                        let str = ''
                        for (let i = 0; i < this.jyType.length; i++) {
                            if (row.JyType == this.jyType[i].value) {
                                str = this.jyType[i].name
                            }
                        }
                        return h('span', {}, str)
                    }
                },
                {
                    title: '分类',
                    key: 'Category',
                    sortable: true,
                    render: (h, { row }) => {
                        let str = ''
                        for (let i = 0; i < this.jyType.length; i++) {
                            if (row.JyType == this.jyType[i].value) {
                                let category = this.jyType[i].children
                                for (let j = 0; j < category.length; j++) {
                                    if (row.Category == category[j].value) {
                                      str = category[j].name
                                  }
                                }
                            }
                        }
                        return h('span', {}, str)
                    }
                },
                {
                    title: '送检人',
                    key: 'Creater',
                    sortable: true
                },
                {
                    title: '提交时间',
                    key: 'Ctime',
                    sortable: true,
                    render: (h, params) => {
                        return h('div', [h('strong', timeFormat(params.row.Ctime))])
                    }
                }
            ], // 表格样式
            dataAll: [], // 表格数据来源
            templist: [],
            dataShow: true, // 是否显示表格数据查看表单
            showTemp: false,
            total: 0,
            orderData: {
                edit: true,
                temp: '',
                type: 1
            },
            jyType: [
                {
                    name: '痕迹',
                    value: 0,
                    children: [
                        {
                            name: '手印',
                            value: 0
                        },
                        {
                            name: '足迹',
                            value: 1
                        },
                        {
                            name: '工具',
                            value: 2
                        },
                        {
                            name: '枪弹',
                            value: 3
                        },
                        {
                            name: '特殊',
                            value: 4
                        },
                        {
                            name: '爆炸',
                            value: 5
                        },
                        {
                            name: '其它',
                            value: 6
                        }
                    ]
                },
                {
                    name: '法医',
                    value: 1,
                    children: [
                        {
                            name: '尸体',
                            value: 0
                        },
                        {
                            name: '活体',
                            value: 1
                        },
                        {
                            name: '其它',
                            value: 2
                        }
                    ]
                },
                {
                    name: 'DNA',
                    value: 2,
                    children: [
                        {
                            name: '案件检验',
                            value: 0
                        },
                        {
                            name: '违法犯罪人员血样',
                            value: 1
                        },
                        {
                            name: '其它',
                            value: 2
                        }
                    ]
                },
                {
                    name: '理化',
                    value: 3,
                    children: [
                        {
                            name: '毒品',
                            value: 0
                        },
                        {
                            name: '毒物',
                            value: 1
                        },
                        {
                            name: '微量物证',
                            value: 2
                        },
                        {
                            name: '酒精含量',
                            value: 3
                        },
                        {
                            name: '其它',
                            value: 4
                        }
                    ]
                },
                {
                    name: '文检',
                    value: 4,
                    children: [
                        {
                            name: '笔记',
                            value: 0
                        },
                        {
                            name: '印章',
                            value: 1
                        },
                        {
                            name: '其他',
                            value: 2
                        }
                    ]
                },
                {
                    name: '电子物证',
                    value: 5,
                    children: [
                        {
                            name: '手机',
                            value: 0
                        },
                        {
                            name: '电脑',
                            value: 1
                        },
                        {
                            name: '存储设备',
                            value: 2
                        },
                        {
                            name: '其它',
                            value: 3
                        }
                    ]
                }
            ],
            jyCategory: []
        }
    },
    components: {
        dtable
    },
    computed: {},
    watch: {},
    methods: {
        getall () {
            this.loading = true
            let data = {
                busyName: 'sf_case'
            }
            this.$api.GetBusyDoing(data).then(res => {
                console.debug(res.Data)
                if (!res.error) {
                    this.dataAll = res.Data
                    if (this.dataAll) {
                        this.total = this.dataAll.length
                    }
                } else {
                    this.$Message.error(res.message)
                }
            })
            this.loading = false
        },

        asyncOK () {
            this.$router.push({
                name: '技术人员审批',
                params: {
                    orderData: this.orderData
                }
            })
        },
        approveClick (data) {
            this.orderData.order = data
            this.orderData.edit = true
            this.$router.push({
                name: '司法检验审核',
                params: {
                    orderData: this.orderData
                }
            })
        },
        get (data) {
            this.orderData.order = data
            this.orderData.edit = false
            this.$router.push({
                name: '司法检验审核',
                params: {
                    orderData: this.orderData
                }
            })
        }
    },
    mounted () {
    // this.getall();
    }
}
</script>
